//
//  main.m
//  OC6_作业练习COLOR
//
//  Created by dllo on 15/11/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import "Color.h"
#import "ColorManager.h"

int main(int argc, const char * argv[]) {

    NSString *filePath = @"/Users/dllo/Desktop/DLS151034/OC6_字典&集合/OC6_字典&集合课后作业/OC6_作业练习/OC6_作业练习COLOR/OC6_作业练习COLOR/File";
    NSString *str = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
//    NSLog(@"%@", str);
    
    NSArray *arr = [str componentsSeparatedByString:@"\n"];
//    NSLog(@"%@", arr);
    
    NSMutableArray *key = [NSMutableArray array];
    NSMutableArray *value = [NSMutableArray array];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    // 字典管理
    
    for (NSInteger i = 0; i < arr.count; i++) {
        NSArray *temp = [[arr objectAtIndex:i] componentsSeparatedByString:@" #"];
        [dic setObject:[temp objectAtIndex:1] forKey:[temp objectAtIndex:0]];
        [key addObject:[temp objectAtIndex:0]];
    }
    
    // 取出所有key, 升序排列
    [key sortUsingSelector:@selector(compare:)];
    
    // 取出所有value, 按照排序后的key排列
    
    for (NSInteger i = 0; i < key.count; i++) {
        [value addObject:[dic objectForKey:[key objectAtIndex:i]]];
    }
    
    
    // 4,新字典管理
    
//    ColorManager *colorList = [[ColorManager alloc] init];
//    
//    for (NSInteger i = 0; i < key.count; i++) {
//        [colorList addColor:[key objectAtIndex:i] colorValue:[value objectAtIndex:i]];
//    }
//    
//    [colorList test:@"P"];
    
    
    
    
    
    return 0;
}
